package com.ruoyi.major.service.impl;

import com.ruoyi.major.domain.Major;
import com.ruoyi.major.mapper.MajorMapper;
import com.ruoyi.major.service.IMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class MajorServiceImpl implements IMajorService {

    @Autowired
    private MajorMapper majorMapper;

    @Override
    public Major selectMajorById(Long id) {
        return majorMapper.selectMajorById(id);
    }

    @Override
    public List<Major> selectMajorList() {
        return majorMapper.selectMajorList();
    }

    @Override
    public int insertMajor(Major major) {
        return majorMapper.insertMajor(major);
    }

    @Override
    public int updateMajor(Major major) {
        return majorMapper.updateMajor(major);
    }

    @Override
    public int deleteMajorByIds(Long[] ids) {
        String idStr = Stream.of(ids).map(String::valueOf).collect(Collectors.joining(","));
        return majorMapper.deleteMajorByIds(idStr);
    }
}
